import os,uuid
from datetime import timedelta
#from redis import Redis
#from flask_uploads import IMAGES

basedir = os.path.abspath(os.path.dirname(__file__))


class BaseConfig(object):
    """
    基础配置
    """
    SQLALCHEMY_TRACK_MODIFICATIONS = False # 屏蔽 sql alchemy 的 FSADeprecationWarning,
    #SQLALCHEMY_TRACK_MODIFICATIONS = False # 屏蔽 sql alchemy 的 FSADeprecationWarning,如果设置成 True (默认情况)，Flask-SQLAlchemy 将会追踪对象的修改并且发送信号。这需要额外的内存， 如果不必要的可以禁用它。

    SEND_FILE_MAX_AGE_DEFAULT =timedelta(seconds=1)#前端静态文件缓存配置，生产需关闭


    SQLALCHEMY_ECHO = True # 打印每次模型操作对应的SQL语句,如果设置为 Ture ， SQLAlchemy 会记录所有 发给 stderr 的语句，这对调试有用。

    # session存储到redis缓存
    SESSION_PERMANENT = True    #session是否长期有效，如False则关闭浏览器session失效
    PERMANENT_SESSION_LIFETIME = 3600    #session长期有效则设定session生命周期，单位是秒
    SESSION_USE_SIGNER = False   #是否对发送到浏览器上session的cookie值进行加密
    #SECRET_KEY = "DC@198668_." #os.urandom(24)    #session，必须设置安全码,
    #SESSION_REFRESH_EACH_REQUEST = True
    SECRET_KEY = "DC@198668_."

    # 令牌配置
    JWT_ACCESS_TOKEN_EXPIRES = timedelta(hours=1)


    # 存储模式
    SESSION_TYPE = 'redis'  #存储到redis中键的前缀
    SESSION_KEY_PREFIX ='flask_cms_session:'  #redis服务器配置，默认使用0库

    #Flask-WTF
    WTF_I18N_ENABLED =False

    #Flask-cache
    #CACHE_TYPE = 'redis'
    CACHE_REDIS_DB = 1  # Redis的db库 (基于零号索引)。默认是0。仅用于RedisCache
    CACHE_KEY_PREFIX = 'flask_cms_cache'
    CACHE_DEFAULT_TIMEOUT = 60 * 60

    #UPLOADS_DEFAULT_DEST = '%s/FILES/' % os.getcwd()#设置默认
    UPLOADED_AIMAGES_DEST = '%s/FILES/AIMAGES' % os.getcwd()
    #UPLOADED_ARTICLEIMAGE_ALLOW = ['gif']
    MAX_CONTENT_LENGTH = 1 * 1024 #* 1024

    JSON_AS_ASCII = False







class DevelopmentConfig(BaseConfig):
    """
    开发环境普通配置
    """
    """
    生产环境普通配置
    """
    DEBUG = True

    #静态文件路径 css,js,jpg,png
    STATIC_FOLDER = '/static/Home'

    # redis
    REDIS_HOST = '10.0.0.88'
    REDIS_PORT = 6379
    REDIS_PASSWORD = 'Dc@198668'

    DB_HOST = '10.0.0.88'
    DB_PORT = '3306'
    DB_DATABASE = 'music'
    DB_USERNAME = 'root'
    DB_PASSWORD = 'dc8668'

    #JWT_SECRET_KEY = '123456@www_newnesslife_com'
    #JWT_ACCESS_TOKEN_EXPIRES = 60*60*60*24#timedelta(hours=1)
    # JWT_HEADER_TYPE = 'JWT'  # 可以修改 请求头中 ，token字符串的 前缀


    SQLALCHEMY_DATABASE_URI = "mysql+pymysql://{username}:{password}@{host}:{port}/{db}?charset=utf8".format(username=DB_USERNAME,
                                                                                                             password=DB_PASSWORD,
                                                                                                             host=DB_HOST,
                                                                                                             port=DB_PORT,
                                                                                                             db=DB_DATABASE)



class ProductionConfig(BaseConfig):
    """
    生产环境普通配置
    """
    DEBUG = True

    #静态文件路径 css,js,jpg,png
    STATIC_FOLDER = '/static/Home'

    # redis
    REDIS_HOST = '10.0.0.88'
    REDIS_PORT = 6379
    REDIS_PASSWORD = 'Dc@198668'

    DB_HOST = '10.0.0.88'
    DB_PORT = '3306'
    DB_DATABASE = 'music'
    DB_USERNAME = 'root'
    DB_PASSWORD = 'dc8668'


    SQLALCHEMY_DATABASE_URI = "mysql+pymysql://{username}:{password}@{host}:{port}/{db}?charset=utf8".format(username=DB_USERNAME,
                                                                                                             password=DB_PASSWORD,
                                                                                                             host=DB_HOST,
                                                                                                             port=DB_PORT,
                                                                                                             db=DB_DATABASE)



